<template>
  <div class="app-container">
    <el-card>
      <el-form ref="form" :model="model" inline>
        <el-form-item>
          <el-button type="success" :icon="Plus">新增</el-button>
        </el-form-item>
        <el-form-item label="">
          <el-input placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :icon="Search">搜索</el-button>
          <el-button :icon="Refresh">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="dataList" class="w-full" border>
        <el-table-column label="序号" type="index" width="60" align="center">
        </el-table-column>
        <el-table-column label="业务员" prop="businessman"> </el-table-column>
        <el-table-column label="关联客户" prop="customers"> </el-table-column>
        <el-table-column
          label="操作"
          prop="operation"
          width="130"
          align="center"
        >
          <template>
            <el-button type="primary" link @click="handleEdit">客户</el-button>
            <el-popconfirm
              title="确认删除"
              @confirm="ElMessage.success('删除成功')"
            >
              <template #reference>
                <el-button type="danger" link>删除</el-button>
              </template>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <CustomerModal :openModal="openModal" @close="openModal = false" />
  </div>
</template>

<script setup>
import { ref } from "vue";
import { provinceList } from "../../../../utils/city";
import { Plus, Refresh, Search } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
import CustomerModal from "./components/CustomerModal.vue";
import useOrderDataStore from "@/store/modules/orderData";
import { salesmanQueryApi } from "@/api/order/customer";

const model = ref({
  brand: "",
  province: "",
  orderTaker: "",
  businessman: "",
});
const dataList = ref([]);
const openModal = ref(false);
const currentIndex = ref(0);

const feature = ref();
onMounted(() => {
  getData();
});
async function getData() {
  const res = await salesmanQueryApi();
  dataList.value = res.Data || [];
}
function handleEdit(type, $index) {
  currentIndex.value = $index;
  openModal.value = true;
}
</script>
